// ===============  The Most Tightly Bound Nuclei ==================

// This program draws a Binding Energy Graph for the nuclides with the highest binding energy per nucleon
// The nuclides were retrieved from the Nucleonica Database

// The material index list of the 10 nuclides with the highest binding energy per nucleon, in decreasing binding energy order
int nuclideList[10] = {280620, 260580, 260560, 280600, 240540, 280640, 240520, 260570, 270590, 280610};

int main()
{
	double BE[10][11];						// Energy Array for the BE(A)-graph
	string Legend[11];						// Legend for the graph: each element has its own colour
	Legend[1] = "25Mn";						// This element is not in the above list
	print("Highest Binding Energies per nucleon:");
	int i;
	for(i=0; i<10; i+=1)
	{
		nuclide nuc;
		nuc.Create(nuclideList[i]/10000, nuclideList[i]%10000/10, 0);	// Create a nuclide object for each nuclide
		BE[i][0] = nuc.A;					// Write the atomic mass number on the X-Axis
		BE[i][nuc.Z-23] = nuc.BindingEnergy;			// Draw a Graph for each element
		Legend[nuc.Z-24] = "" + nuc.Z + nuc.Element;		// and print its legend
								// display the Element / Binding Energy table
		print("" + nuc.Z + " " + nuc.Element + nuc.A + "             " + format(nuc.BindingEnergy, "0.000000") + " MeV");
  	}
	print(" ");
	graph GraphBE;
	GraphBE.GraphTitles("Maximum Binding Energies", Legend);		// Graph title and legend
	GraphBE.GraphGrid(1,1, 1,0);					// Major and Minor X and Y grid-lines
	GraphBE.GraphStyle("Symbol", 1, 1, 1, 1);				// LineStyle, TickLocation, show Border, Legend, GraphBorder
	GraphBE.GraphAutoScale(0,0, 51,65, 8.75, 8.80);			// Set X and Y scale
	GraphBE.GraphConfigure("Atomic Mass Number, A", "Binding Energy per nucleon, MeV", 0,0, 600, 400);
	print(GraphBE.drawGraph(BE));					// draw the Binding  Energy Graph
}